package com.tedu.api.list;

import java.util.Collection;

public class Fruit {
    private String name;

    public String getName() {
        return name;
    }
    public Fruit (String name){
        this.name =name;
    }
}
//创建两个子类：Apple和Orange继承Fruit
class Apple extends Fruit{
    public Apple(String name) {
        super("苹果");
    }
}
class Orange extends Fruit{
    public Orange(String name) {
        super("橘子");
    }
}
//创建TestJob类--静态方法printFruit：添加约束：传入类型一定是父类的子类
class TestJob{
    public static void printFruit(Collection<? extends Fruit> fruits){
        for (Fruit fruit:fruits){
            System.out.println(fruit.getName());
        }
    }
}




























